#include <stdio.h>

int main() {
    int a;
    int b = 0, c = 0, d = 0, e = 0;

    while (scanf("%d", &a) == 1 && a != -1) {
        switch (a) {
            case 1: b++; break;
            case 2: c++; break;
            case 3: d++; break;
            case 0:
            case 4: e++; break;
        }
    }

    printf("Tom = %d Jerry = %d Spike = %d Invalid = %d\n", b, c, d, e);

    if (b <= e && c <= e && d <= e) {
        printf("Election invalid!\n");
    }

    return 0;
}
